
function initExt(viewModel, requestUtils) {

  // cb.utils.alert("测试详情业务逻辑")
  //获取了一个名为actual_modify的数据模型字段。
  //并为actual_modify字段添加了一个事件监听器。
  viewModel.get("actual_modify").on('afterValueChange', function (data) {

    debugger
    let value = data.value || 0;
    // 下拨预算
    let budget = viewModel.get("budget").getValue() || 0;
    // 实际占用
    let actual_occupy = viewModel.get("actual_occupy").getValue() || 0
    // 经费总额
    let total_budget = budget + value
    // 实际可用
    let actual_budget = total_budget - actual_occupy
    viewModel.get("total_budget").setValue(total_budget)
    viewModel.get("actual_budget").setValue(actual_budget)

  })
  //实际调整数
  viewModel.get("budget").on('afterValueChange', function (data) {

    debugger
    // 下拨预算
    let budget = viewModel.get("budget").getValue() || 0;
    // 实际占用
    let actual_occupy = viewModel.get("actual_occupy").getValue() || 0

    let actual_modify = viewModel.get("actual_modify").getValue() || 0
    // 经费总额
    let total_budget = budget + actual_modify
    // 实际可用
    let actual_budget = total_budget - actual_occupy
    viewModel.get("total_budget").setValue(total_budget)
    viewModel.get("actual_budget").setValue(actual_budget)

  })



};



cb.define(process.env.__DOMAINKEY__, ['common/requestUtils.js'], function (requestUtils) {
  let vm = {
    doAction: function (name, viewModel) {
      if (this[name])
        this[name](viewModel);
    },
    init: function (viewModel) {
      initExt(viewModel, requestUtils);
    }
  }
  try {
    module.exports = vm;
  } catch (error) {
    console.log(error);
  }
  return vm;
});